<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    123
    <script>
        let p = new Promise((resolve,reject)=>{
            setTimeout(()=>{
                // let a = 'a'
                let a = 'b'
                if(a == 'a'){
                    resolve('成功')
                }else{
                    reject('失败')
                }
            },1000)
        }).then(res=>{
            console.log(res);
        },err =>{
            console.log(err);
        });
        const p1 = () => {
        return new Promise((resolve,reject)=>{
            setTimeout(()=>{
                console.log('p1触发了');
                resolve()
            
            },2000)
        })
        }
        const p2 = () => {
        return new Promise((resolve,reject)=>{
            setTimeout(()=>{
                console.log('p2触发了');
                resolve()
            
            },1500)
        })
        }
        const p3 = () => {
        return new Promise((resolve,reject)=>{
            setTimeout(()=>{
                console.log('p3触发了');
                resolve()
            
            },3000)
        })
        }
        // p1()
        // p2()
        // p3()


    //     p1()
    //     .then(() =>{
    //         return p2()
    //     })
    //     .then(()=>{
    //        return p3()
    //     })
    //     .then(()=>{
    // console.log("谢谢");
    //     }).catch(err =>{
    //         console.log(err);
    //     })

    // const test = async () =>{
    //     await p1()
    //     await p2()
    //     await p3()
    // }
    // test().catch(err=>{
    //     console.log(err);
    // })

    const test = async () =>{
        const count = 4
        await p1()
        if(count == 5){
            await p2()
        }else{
            console.log(123);
            return;
        }
        await p3()
    }
    test()
    </script>
</body>
</html>